package com.hero.listener;

import cn.hutool.json.JSONUtil;
import com.hero.domain.CoursePublish;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * @author yunfei
 * @date 2022年12月31日 16:21
 */
@Component
public class CoursePublishRedisListener {

    @RabbitListener(bindings = @QueueBinding(
            exchange = @Exchange(name = "coursePublish", type = "fanout"),
            value = @Queue(name = "redisMQ")
    ))
    public void coursePublishRedisConsumer(String publishStr) {
        CoursePublish coursePublish = JSONUtil.toBean(publishStr, CoursePublish.class);
        System.out.println("coursePublish = " + coursePublish);
    }
}